Hello!

Recently I’ve got an Asus Tinkerboard single-board computer. This SBC is very interesting – it has pin compatibility with Raspberry Pi, but it is much faster than Pi. BTW, I’ve using it in my Pi-top, and it fits in place of Raspberry, and works well!

 

But, Tinkerboard don’t have community that Raspberry has, and it don’t have such selection of OS images out of the box. Well, let’s fix it and install Gentoo!

First of all, let’s take a look on similarities and differences.
– Tinkerboard and Raspberry Pi 3 both compatible with ARMv7 instruction set. So theoretically what works on Raspberry – should at least try to work on Tinkerboard;
– Different peripheral controllers. Yes, it is pin-out compatible with Raspberry, but have anoter SOC, so code that works, for example, with I2C, will not work without modifications;
– Most interesting – different booting process. While Raspberry uses proprietary bootloader, which reads first VFAT partition of SD card and executes kernel (so you just need two partitions on card – boot with kernel and other boot stuff, and rootfs – and nothing more), Tinkerboard uses u-boot process – you still need two partitions, like on Raspberry, but you also will need to have U-boot binary to be at special offset of SD card (usually 0x40). So we can’t just use SD card from Raspberry – it will not work.

Step 1. Preparing SD card.

To make Tinerboard up and running, we will need SD card with two partitions (boot, root) and special bootloader in place (it is not in /boot partition, and it is can’t be seen with fdisk -p). Easiest way to do this – is write Debian image for Tinkerboard, and then change root partition contents to Gentoo.
Please download Debian for Tinkerboard image here , and Etcher image writer here – and write image to your MicroSD card. When write will be complete, insert card to Tinkerboard and power it up – this will make root partition expand to full card size (or you can just remove second partition with fdisc and create new one with correct size).

Step 2. Writting Gentoo stage tarball on SD card.

After step 1, we have bootable microSD for Tinkerboard. Now we just need to change rootfs contents to Gentoo.

Create new filesystem:

mkfs.ext4 /dev/sdb2 (here sdb2 – is second partition of microSD card. Be careful, double-check if you supplied correct parition parameter!)

Download Gentoo stage3 tarball for Armv7 here (we need stage3 for Armv7-hardfp), copy it to your new root partiton, and extract. Commands should be like this:
(if new partition isn’t mounted) mount /dev/sdb2 /mnt/gentoo
cd /mnt/gentoo
cp ~/Downloads/stage3-armv7a_hardfp-20161129.tar.bz2 ./
tar xpjf stage3-armv7a_hardfp-20161129.tar.bz2 -C ./

When it will finish, please alter /etc/shadow file – or you will unable to login when system will be booted. You need to remove “*” symbol from password for root user. String for root user should looks like:
root::15723:0::::

After this, umount your new rootfs, insert card to Tinerboard, and boot! Log in with “root” user with empty password.

Step 3. Kernel compiling.

Your board now should be more alive than dead, but there is no WiFi. To bring it up, we need to recompile kernel and modules.
Kernel compiling manual mostly taken from here.

First, install bc application:

emerge bc

Clone kernel:

git clone https://github.com/TinkerBoard/debian_kernel.git
 cd ./debian_kernel/
 git checkout linux4.4-rk3288
Create kernel config from current kernel:
 make ARCH=arm miniarm-rk3288_defconfig

It seems like not all good with kconfig files in this branch – if you run “make menuconfig”, your .config file will be broken.
I’ve maded this changes with .config file to make system little cooler:

@@ -565,8 +565,8 @@
 # CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
 # CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE is not set
 # CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
 -CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
 -# CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE is not set
 +# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
 +CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE=y
 # CONFIG_CPU_FREQ_DEFAULT_GOV_INTERACTIVE is not set
 # CONFIG_CPU_FREQ_DEFAULT_GOV_SCHED is not set
 # CONFIG_CPU_FREQ_DEFAULT_GOV_SCHEDUTIL is not set
 @@ -576,8 +576,8 @@
 CONFIG_CPU_FREQ_GOV_ONDEMAND=y
 CONFIG_CPU_FREQ_GOV_INTERACTIVE=y
 CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
 -# CONFIG_CPU_FREQ_GOV_SCHED is not set
 -# CONFIG_CPU_FREQ_GOV_SCHEDUTIL is not set
 +CONFIG_CPU_FREQ_GOV_SCHED=y
 +CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y

#
 # CPU frequency scaling drivers
 @@ -598,7 +598,7 @@
 #
 # ARM CPU Idle Drivers
 #
 -# CONFIG_ARM_CPUIDLE is not set
 +CONFIG_ARM_CPUIDLE=y
 # CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED is not set

For GCC6 – you probably will need to apply this changes :

diff --git a/drivers/media/i2c/soc_camera/rockchip/Makefile b/drivers/media/i2c/soc_camera/rockchip/Makefile
index 7933bcd1..2486999a 100755
--- a/drivers/media/i2c/soc_camera/rockchip/Makefile
+++ b/drivers/media/i2c/soc_camera/rockchip/Makefile
@@ -1,2 +1,3 @@
 obj-\$(CONFIG_VIDEO_OV8858) += ov_camera_module.o rk_camera_module.o ov8858_v4l2-i2c-subdev.o
 obj-\$(CONFIG_VIDEO_IMX219) += imx_camera_module.o rk_camera_module.o imx219_v4l2-i2c-subdev.o
+ccflags-y += -Wno-misleading-indentation # GCC6
diff --git a/drivers/net/wireless/rockchip_wlan/rtl8723bs/Makefile b/drivers/net/wireless/rockchip_wlan/rtl8723bs/Makefile
index 40715655..bd33c700 100644
--- a/drivers/net/wireless/rockchip_wlan/rtl8723bs/Makefile
+++ b/drivers/net/wireless/rockchip_wlan/rtl8723bs/Makefile
@@ -16,6 +16,7 @@ EXTRA_CFLAGS += -Wno-unused
 #EXTRA_CFLAGS += -Wno-uninitialized
 #EXTRA_CFLAGS += -Wno-error=date-time  # Fix compile error on gcc 4.9 and later

+EXTRA_CFLAGS += -Wno-misleading-indentation # GCC6
 EXTRA_CFLAGS += -I\$(src)/include
 EXTRA_CFLAGS += -I\$(src)/hal/phydm

And, after all, run build for kernel and modules:

make ARCH=arm -j5 zImage
make ARCH=arm -j5 modules
make ARCH=arm dtbs
And last step - install your new kernel and modules:
 mount /dev/mmcblk0p1 /boot/
 mv /boot/zImage /boot/zImage.bak
 mv /boot/rk3288-miniarm.dtb /boot/rk3288-miniarm.dtb.bak
 cp ./arch/arm/boot/zImage /boot/
 cp ./arch/arm/boot/dts/rk3288-miniarm.dtb /boot/
 umount /boot/

Reboot, and enjoy working WiFi 🙂